<?php
class ModuleProfileVo extends SzAbstractMySqlVo
{

    private $userId;
    private $level;
    private $exp;
    private $freeToken;
    private $purchasedToken;
    private $commodityValue;
    private $energy;
    private $energyLimit;
    private $lastEnergyChargedTime;
    private $registerTime;
    private $lastLoginTime;
    private $targetId;
    private $coolingTime;

    /**
     * Initialize ModuleProfileVo.
     *
     * @param $userId
     * @param $level
     * @param $exp
     * @param $freeToken
     * @param $purchasedToken
     * @param $commodityValue
     * @param $energy
     * @param $energyLimit
     * @param $lastEnergyChargedTime
     * @param $registerTime
     * @param $lastLoginTime
     * @param $targetId
     * @param $coolingTime
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return ModuleProfileVo
     */
    public function __construct($userId, $level, $exp, $freeToken, $purchasedToken, $commodityValue, $energy, $energyLimit, $lastEnergyChargedTime, $registerTime, $lastLoginTime, $targetId = 0, $coolingTime = 0, $isInsert = false) {
        $this->userId = $userId;
        $this->level = $level;
        $this->exp = $exp;
        $this->freeToken = $freeToken;
        $this->purchasedToken = $purchasedToken;
        $this->commodityValue = $commodityValue;
        $this->energy = $energy;
        $this->energyLimit = $energyLimit;
        $this->lastEnergyChargedTime = $lastEnergyChargedTime;
        $this->registerTime = $registerTime;
        $this->lastLoginTime = $lastLoginTime;
        $this->targetId = $targetId;
        $this->coolingTime = $coolingTime;

        $this->isInsert = $isInsert;
        $this->voClassName = 'ModuleProfileVo';
        $this->ormName = 'ModuleProfile';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'level' => $this->getLevel(),
            'exp' => $this->getExp(),
            'token' => $this->getToken(),
            'freeToken' => $this->getFreeToken(),
            'purchasedToken' => $this->getPurchasedToken(),
            'commodityValue' => $this->getCommodityValue(),
            'energy' => $this->getEnergy(),
            'energyLimit' => $this->getEnergyLimit(),
            'lastEnergyChargedTime' => $this->getLastEnergyChargedTime(),
            'registerTime' => $this->getRegisterTime(),
            'lastLoginTime' => $this->getLastLoginTime(),
            'targetId' => $this->getTargetId(),
            'coolingTime' => $this->getCoolingTime(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'level' => $this->getLevel(),
            'exp' => $this->getExp(),
            'freeToken' => $this->getFreeToken(),
            'purchasedToken' => $this->getPurchasedToken(),
            'commodityValue' => $this->getCommodityValue(),
            'energy' => $this->getEnergy(),
            'energyLimit' => $this->getEnergyLimit(),
            'lastEnergyChargedTime' => $this->getLastEnergyChargedTime(),
            'registerTime' => $this->getRegisterTime(),
            'lastLoginTime' => $this->getLastLoginTime(),
            'targetId' => $this->getTargetId(),
            'coolingTime' => $this->getCoolingTime(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getLevel(),
            $this->getExp(),
            $this->getFreeToken(),
            $this->getPurchasedToken(),
            $this->getCommodityValue(),
            $this->getEnergy(),
            $this->getEnergyLimit(),
            $this->getLastEnergyChargedTime(),
            $this->getRegisterTime(),
            $this->getLastLoginTime(),
            $this->getTargetId(),
            $this->getCoolingTime(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getLevel()
    {
        return $this->level;
    }

    public function setLevel($val)
    {
        $this->saveColumnStatus(1, $this->level);
        $this->level = $val;
    }

    public function getExp()
    {
        return $this->exp;
    }

    public function setExp($val)
    {
        $this->saveColumnStatus(2, $this->exp);
        $this->exp = $val;
    }

    public function getFreeToken()
    {
        return $this->freeToken;
    }

    public function setFreeToken($val)
    {
        $this->saveColumnStatus(3, $this->freeToken);
        $this->freeToken = $val;
    }

    public function updateFreeToken($val)
    {
        $this->saveColumnStatus(3, $this->freeToken);
        $this->freeToken += $val;
    }

    public function getPurchasedToken()
    {
        return $this->purchasedToken;
    }

    public function setPurchasedToken($val)
    {
        $this->saveColumnStatus(4, $this->purchasedToken);
        $this->purchasedToken = $val;
    }

    public function updatePurchasedToken($val)
    {
        $this->saveColumnStatus(4, $this->purchasedToken);
        $this->purchasedToken += $val;
    }

    public function getCommodityValue()
    {
        return $this->commodityValue;
    }

    public function setCommodityValue($val)
    {
        $this->saveColumnStatus(5, $this->commodityValue);
        $this->commodityValue = $val;
    }

    public function updateCommodityValue($val)
    {
        if (is_float($val)) {
            $val = floor($val);
        }

        $this->saveColumnStatus(5, $this->commodityValue);
        $this->commodityValue += $val;
    }

    public function getEnergy()
    {
        return $this->energy;
    }

    public function setEnergy($val)
    {
        $this->saveColumnStatus(6, $this->energy);
        $this->energy = $val;
    }

    public function getEnergyLimit()
    {
        return $this->energyLimit;
    }

    public function setEnergyLimit($val)
    {
        $this->saveColumnStatus(7, $this->energyLimit);
        $this->energyLimit = $val;
    }

    public function getLastEnergyChargedTime()
    {
        return $this->lastEnergyChargedTime;
    }

    public function setLastEnergyChargedTime($val)
    {
        $this->saveColumnStatus(8, $this->lastEnergyChargedTime);
        $this->lastEnergyChargedTime = $val;
    }

    public function getRegisterTime()
    {
        return $this->registerTime;
    }

    public function setRegisterTime($val)
    {
        $this->saveColumnStatus(9, $this->registerTime);
        $this->registerTime = $val;
    }

    public function getLastLoginTime()
    {
        return $this->lastLoginTime;
    }

    public function setLastLoginTime($val)
    {
        $this->saveColumnStatus(10, $this->lastLoginTime);
        $this->lastLoginTime = $val;
    }

    public function getPropertyValue($propertyName)
    {
        return $this->$propertyName;
    }

    /**
     * Get user token amount.
     * @return int $token
     */
    public function getToken()
    {
        return $this->freeToken + $this->purchasedToken;
    }

    public function getTargetId()
    {
        return $this->targetId;
    }

    public function setTargetId($val)
    {
        $this->saveColumnStatus(11, $this->targetId);
        $this->targetId = $val;
    }

    public function getCoolingTime()
    {
        return $this->coolingTime;
    }

    public function setCoolingTime($val)
    {
        $this->saveColumnStatus(12, $this->coolingTime);
        $this->coolingTime = $val;
    }

}